package es.tikitaka.dictionary;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import es.tikitaka.domain.Partido;

/**
 * 
 * @author Saúl Domínguez
 * @since 2010
 * @category PFC
 */

@Entity
@Table(name = "HORASDIC")
public class HorasDic {

	private Integer id;
	private String hora;
	private Set<Partido> m_partidos;

	/**
	 * Constructor por defecto
	 */
	public HorasDic() {
		// TODO Auto-generated constructor stub
	}

	/*
	 * getters and setters
	 */

	/**
	 * 
	 * @return id Id de la hora
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "HOR_GEN")
	@SequenceGenerator(allocationSize = 1, name = "HOR_GEN", sequenceName = "HOR_SEQ")
	@Column(name = "X_HOR", nullable = false, precision = 10, scale = 0)
	public Integer getId() {
		return id;
	}

	/**
	 * 
	 * @param id
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * 
	 * @return hora Horas disponibles
	 */
	@Column(name = "HORA")
	public String getHora() {
		return hora;
	}

	/**
	 * 
	 * @param hora
	 */
	public void setHora(String hora) {
		this.hora = hora;
	}

	/**
	 * 
	 * @return partidos Conjunto de partidos para una hora determinada
	 */
	@Column(name = "M_PARTIDOS")
	@OneToMany(mappedBy = "hora", fetch = FetchType.LAZY)
	public Set<Partido> getM_partidos() {
		return m_partidos;
	}

	/**
	 * 
	 * @param m_partidos
	 */
	public void setM_partidos(Set<Partido> m_partidos) {
		this.m_partidos = m_partidos;
	}

	/**
	 * Método equals
	 */
	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof HorasDic)) {
			return false;
		}
		if (obj != null) {
			if (this.id == ((HorasDic) obj).getId()) {
				return true;
			}
		}
		return false;
	}

	/**
	 * Método hashCode
	 */
	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		return super.hashCode();
	}

}
